<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
</html>

<script>
    var json1 = '{"id":1,"name":"zx","age":18}';

    var json2 = '[{"id":1,"name":"zx","age":18},{"id":2,"name":"zc","age":18}]';

    var json3 = '{"id":1,"name":"zx","age":18,"dept":{"id":5,"name":"开发部"}}';

    var jsObj1 = {"id":1,"name":"zx","age":18};
    var jsObj2 = {id:1,name:"zz",age:18};

    //json  字符串 转 js 对象
    console.log(JSON.parse(json1).age);
    console.log(JSON.parse(json2));
    console.log(JSON.parse(json3).dept.name);

    //js对象 转 json 字符串
    console.log(JSON.stringify(jsObj2));


</script>